use crate::model::DefineConfigAst;
use crate::traits::ObjectLitTrait;
use swc_ecma_ast::*;

pub trait ViteConfigUpdatedModuleTrait {
    fn get_define_config_ast(&self) -> DefineConfigAst;

    fn try_get_server_node(&self) -> Option<ObjectLit>;

    fn try_get_proxy_node(&self) -> Option<ObjectLit> {
        self.try_get_server_node()
            .and_then(|server_node| server_node.try_get_object_value("proxy"))
    }

    fn try_get_resolve_node(&self) -> Option<ObjectLit>;

    fn try_get_alias_node(&self) -> Option<ObjectLit> {
        self.try_get_resolve_node()
            .and_then(|resolve_node| resolve_node.try_get_object_value("alias"))
    }
}
